package org.atlantis.juc.actor;

public class ActorUsage {

	static class Counter extends Actor<Integer> {

		private int value = 0;

		@Override
		protected void receive(Integer message) {
			if (message == -1) {
				exit();
				System.err.println("Exited!!! Value = " + value);
			}

			value += message;
		}
	}

	public static void main(String[] args) {
		Counter counter = new Counter();
		for (int i = 0; i < 10000; i++)
			counter.post(i);
		counter.post(-1);
	}
}
